import request from '@/utils/request';

/**
 * 分页查询库存
 */
export async function pageProductStorage(params) {
  const res = await request.get('/store/productStorage/page', { params });
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 分页查询库存
 */
export async function pageNoStorageNums(params) {
  const res = await request.get('/store/productStorage/pageNoStorageNums', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询库存列表
 */
export async function listProductStorage(params) {
  const res = await request.get('/store/productStorage', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询库存列表
 */
export async function listProductStoragetSel(params) {
  const res = await request.get('/store/productStorage/listSel', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询库存
 */
export async function productStorageNum(params) {
  const res = await request.get('/store/productStorage/productStorageNum', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询库存
 */
export async function getProductStorage(id) {
  const res = await request.get('/store/productStorage/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加库存
 */
export async function addProductStorage(data) {
  const res = await request.post('/store/productStorage', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改库存
 */
export async function updateProductStorage(data) {
  const res = await request.put('/store/productStorage', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除库存
 */
export async function removeProductStorage(id) {
  const res = await request.delete('/store/productStorage/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
